<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="小龙的个人博客">
    <meta name="description" content="大数据架构师指南">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>小龙的个人博客</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 5.0.0"><link rel="alternate" href="/atom.xml" title="小龙的个人博客" type="application/atom+xml">
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">小龙的个人博客</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">小龙的个人博客</div>
        <div class="logo-desc">
            
            大数据架构师指南
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://gitee.com/carlosgxl" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://gitee.com/carlosgxl" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/0.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title"></h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                          <div class="article-tag">
                            <span class="chip bg-color">无标签</span>
                          </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-08-10
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="一、项目简介"><a href="#一、项目简介" class="headerlink" title="一、项目简介"></a>一、项目简介</h1><h2 id="1、项目背景"><a href="#1、项目背景" class="headerlink" title="1、项目背景"></a>1、项目背景</h2><p>1） 电商模式</p>
<p>市面上有 5 中常见的电商模式 B2B、B2C、C2B、C2C、O2O；</p>
<ul>
<li>B2B 模式<ul>
<li>B2B （Business to Business）,是指商家与商家建立的商业关系。如：阿里巴巴</li>
</ul>
</li>
<li>B2C 模式<ul>
<li>B2C（Business to Consumer）,就是我们经常看到的供应商直接把商品卖给用户，即 ”商对客“ 模式，也即是通常说的商业零售，直接面向消费者销售产品。如：苏宁易购，京东、天猫、小米商城</li>
</ul>
</li>
<li>C2B 模式<ul>
<li>C2B（Customer to Business）,即消费者对企业，先有消费者需求产生后而后有企业生产，即先有消费者提出需求，后有生产企业按需求组织生产</li>
</ul>
</li>
<li>C2C 模式<ul>
<li>C2C（Customer to Customer）,客户之间自己把东西放网上去卖，如：淘宝，咸鱼</li>
</ul>
</li>
<li>O2O 模式<ul>
<li>O2O 即 Online To Online，也即将线下商务的机会与互联网结合在了一起，让互联网成为线下交易的前台。线上快速支付，线下优质服务。如：饿了吗，美团，淘票票，京东到家。</li>
</ul>
</li>
</ul>
<p>2）高斯商城</p>
<p>高斯商城是一个 B2C 模式的电商平台，销售自营商品给客户。</p>
<h2 id="2、项目架构图"><a href="#2、项目架构图" class="headerlink" title="2、项目架构图"></a>2、项目架构图</h2><h3 id="1、项目微服务架构图"><a href="#1、项目微服务架构图" class="headerlink" title="1、项目微服务架构图"></a>1、项目微服务架构图</h3><p><img src="image-20200803163509492.png" alt="image-20200803163509492"></p>
<h3 id="2、微服务划分图"><a href="#2、微服务划分图" class="headerlink" title="2、微服务划分图"></a>2、微服务划分图</h3><p><img src="image-20200803163708727.png" alt="image-20200803163708727"></p>
<h2 id="3、项目技术-amp-特色"><a href="#3、项目技术-amp-特色" class="headerlink" title="3、项目技术&amp;特色"></a>3、项目技术&amp;特色</h2><ul>
<li>前后端分离开发，并开发基于 vue 的后台管理系统</li>
<li>SpringCloud 全新的解决方案</li>
<li>应用监控、限流、网关、熔断降级等分布式方案 全方位开发设计</li>
<li>透彻讲解分布式事务、分布式锁等分布式系统的难点</li>
<li>分析高并发场景的编码方式，线程池，异步编排等使用</li>
<li>压力测试和性能优化</li>
<li>CI/CD 使用</li>
<li>…</li>
</ul>
<h2 id="4、项目前置要求"><a href="#4、项目前置要求" class="headerlink" title="4、项目前置要求"></a>4、项目前置要求</h2><p>学习项目的前置知识</p>
<ul>
<li>熟悉 SpringBoot 以及常见整合方案</li>
<li>了解 SpringCloud</li>
<li>熟悉 git maven</li>
<li>熟悉 linux redis, docker 等操作</li>
<li>了解 html css js vue</li>
<li>熟练使用 idea 开发项目</li>
<li>…</li>
</ul>
<h1 id="二、分布式基础概念"><a href="#二、分布式基础概念" class="headerlink" title="二、分布式基础概念"></a>二、分布式基础概念</h1><h2 id="1、微服务"><a href="#1、微服务" class="headerlink" title="1、微服务"></a>1、微服务</h2><p>​        微服务架构风格，就像是一个==单独的应用程序==开发成==一套小服务==，每个==小服务==运行在自己的==进程==中，并使用轻量级机制通信，通常是 HTTP API。这些服务围绕业务能力来构建，并通过完全自动化部署机制来独立部署。这些服务使用不同的语言编写，以及不同数据存储技术，并保持最低限度的集中式管理。</p>
<p>==简而言之：拒绝大型单体应用，基于业务边界进行服务微化拆分，各个五福独立部署运行。==</p>
<p><img src="image-20200803155826838.png" alt="微服务"></p>
<h2 id="2、集群-amp-分布式-amp-节点"><a href="#2、集群-amp-分布式-amp-节点" class="headerlink" title="2、集群 &amp; 分布式 &amp; 节点"></a>2、集群 &amp; 分布式 &amp; 节点</h2><p>集群是个物理形态，分布式是个工作方式。</p>
<p>只要是一堆机器，就可以叫集群，他们是不是一起协作着干活，这个谁也不知道；</p>
<pre class=" language-java"><code class="language-java">《分布式系统原理与范型》定义：
”分布式系统是由若干独立计算机的集合，这些计算机对于用户来说就像单个相关系统“
分布式系统（distributed system）是建立在网络之上的软件系统。</code></pre>
<p>分布式是将不同的业务分布在不同的地方。</p>
<p>集群指的是将几台服务器集中在一起，实现统一业务。</p>
<p>例如：==京东是一个分布式系统，众多业务运行在不同的机器，==所有业务构成一个大型的==业务集群==。每一个小的业务，比如用户系统，  访问压力大的时候一台服务器是不够的。我们就应该将用户系统部署到多个服务器，也就是==每一个业务系统也可以做集群化==；</p>
<p>==分布式中的每一个节点，都可以做集群，而集群并不一点是分布式的。==</p>
<p>节点：集群中的一个服务器。</p>
<h2 id="3、远程调用"><a href="#3、远程调用" class="headerlink" title="3、远程调用"></a>3、远程调用</h2><p>在分布式系统中，各个服务可能处于不同主机，但是服务之间不可避免的需要互相调用，我们称之为远程调用</p>
<p>SpringCloud 中使用 HTTP+JSON 的方式完成远程调用</p>
<p><img src="image-20200803160948944.png" alt="image-20200803160948944"></p>
<h2 id="4、负载均衡"><a href="#4、负载均衡" class="headerlink" title="4、负载均衡"></a>4、负载均衡</h2><p><img src="image-20200803161056102.png" alt="image-20200803161056102"></p>
<p>​    分布式系统中，A 服务需要调用 B 服务，B 服务在多台机器中都存在。A 调用任意一个服务器均可完成功能。</p>
<p>​    为了使每一个服务器都不要太忙或者太闲，我们可以负载均衡的调用每一个服务器，提升网站的健壮性。</p>
<p>​    <strong>常见负载均衡算法</strong></p>
<p>​    <strong>轮询</strong>：为第一请求选择健康池中的第一个后端服务器，然后按顺序往后依次选择，直到最后一个，然后循环</p>
<p>​    <strong>最小连接</strong>： 优先选择连接数最少，也就是压力最小的后端服务器，在会话较长的情况下可以考虑采取这种方式。</p>
<p>​    <strong>散列</strong>：根据请求员的 IP 的散列（hash）来选择要转发的服务器。这种方式恶意一定程度上保证特定用户能连接到相同的服务器。如果你的应用需要处理状态而要求用户能连接到和之前相同的服务器，可以考虑采取这种方式。</p>
<h2 id="5、服务注册-发现-amp-注册中心"><a href="#5、服务注册-发现-amp-注册中心" class="headerlink" title="5、服务注册/发现&amp;注册中心"></a>5、服务注册/发现&amp;注册中心</h2><p>A 服务调用 B 服务，A 服务并不知道 B 服务当前在哪几台服务器有，哪些正常的，那些服务已经下线。解决这个问题可以引入注册中心；</p>
<p><img src="image-20200803161942999.png" alt="image-20200803161942999"></p>
<p>​     如果某些服务下线，我们其他人可以实时的感知到其他服务的状态。从而避免调用不可用的服务</p>
<h2 id="6、配置中心"><a href="#6、配置中心" class="headerlink" title="6、配置中心"></a>6、配置中心</h2><p><img src="image-20200803162159955.png" alt="image-20200803162159955"></p>
<p>每一个服务最终都要大量的配置，并且每个服务都可能部署在多台机器上。我们经常需要变更配置，我们可以将每个服务在配置中心获取自己的位置</p>
<p>​    ==配置中心用来集中管理微服务的配置信息。==</p>
<h2 id="7、服务熔断-amp-服务降级"><a href="#7、服务熔断-amp-服务降级" class="headerlink" title="7、服务熔断&amp;服务降级"></a>7、服务熔断&amp;服务降级</h2><p>​        在微服务架构中，微服务之间通过网络进行通信，存在相互依赖，当其中一个服务不可用时，有可能造成雪崩效应。要防止这样的情况，必须要有容错机制来保护服务。</p>
<p><img src="image-20200803162623325.png" alt="image-20200803162623325"></p>
<p>1）、服务熔断</p>
<p>​    a、设置服务的超时，当被调用的服务经常失败到达某个阈值，我们可以开启断路保护机制，后来的请求不再去调用这个服务。本地直接返回默认的数据。</p>
<p>2）、服务降级</p>
<p>​    a、在运维期间，当系统处于高峰期，系统资源紧张，我们可以让非核心业务降级运行。降级：某些服务不处理，或者简单吹</p>
<p>  【抛异常、返回 NULL、调用 Mock 数据、调用 Fallback 处理逻辑】。</p>
<h2 id="8、API-网关"><a href="#8、API-网关" class="headerlink" title="8、API 网关"></a>8、API 网关</h2><p>在微服务架构中，API Gateway 作为整体架构的重要组件，它==抽象了微服务中都需要的公共功能==，同时提供了客户端==负载均衡，服务自动熔断，灰度发布，统一认证，限流监控，日志统计==等丰富的功能，帮助我们解决很多 API 管理难题。</p>
<p><img src="image-20200803163414476.png" alt="image-20200803163414476"></p>
<h1 id="三、环境搭建"><a href="#三、环境搭建" class="headerlink" title="三、环境搭建"></a>三、环境搭建</h1><h2 id="1、安装-Linux"><a href="#1、安装-Linux" class="headerlink" title="1、安装 Linux"></a>1、安装 Linux</h2><h3 id="1、三种方式"><a href="#1、三种方式" class="headerlink" title="1、三种方式"></a>1、三种方式</h3><ol>
<li>使用 Oracle VM VirtualBox + Vagrant 实现</li>
<li>使用 VMware 实现</li>
<li>使用云服务器</li>
</ol>
<h3 id="2、-VirtualBox-Vagrant-安装"><a href="#2、-VirtualBox-Vagrant-安装" class="headerlink" title="2、 VirtualBox + Vagrant 安装"></a>2、 VirtualBox + Vagrant 安装</h3><ul>
<li><p>下载安装 VirtualBox <a target="_blank" rel="noopener" href="https://www.virtualbox.org/">https://www.virtualbox.org/</a> ，要开启CPU虚拟化</p>
</li>
<li><p>下载安装 Vagrant</p>
<ul>
<li>下载 <a target="_blank" rel="noopener" href="https://www.vagrantup.com/">https://www.vagrantup.com/</a></li>
<li>镜像仓库 <a target="_blank" rel="noopener" href="https://app.vagrantup.com/boxes/search">https://app.vagrantup.com/boxes/search</a></li>
</ul>
</li>
<li><p>打开 window cmd 窗口，运行 Vagrant init centos/7 ，即可初始化一个 centos7 系统</p>
</li>
<li><p>运行 vagrant up 即可启动虚拟机（在电脑当前用户目录下有 Vagrantfile 文件）。系统 root 用户的密码是 vagrant</p>
</li>
<li><p>vagrant 其他常用命令</p>
<ul>
<li><code>vagrant ssh</code> ：自动使用 vagrant 用户连接虚拟机<ul>
<li><code>vagrant upload source [destination][name|id]</code> ：上传文件</li>
</ul>
</li>
<li>vagrant 命令行 ：<a target="_blank" rel="noopener" href="https://www.vagrantup.com/docs/cli/init">https://www.vagrantup.com/docs/cli/init</a></li>
</ul>
</li>
<li><p>默认虚拟机的 ip 地址不是固定 ip ，开发不方便</p>
<ul>
<li><p>修改 Vagrantfile</p>
<pre><code>config.vm.network "private_network",ip: "192.168.56.10"

这里的 ip 需要在物理机下使用 ipconfig 命令找到

VirtualBox 的地址是 192.168.56.1 这里我们选择将 Vagrantfile ip 修改为 192.168.56.10</code></pre>
<p><img src="https://oscimg.oschina.net/oscnet/up-0748de9b53b6f4e0e1a028b08d4f9aa14fe.png" alt="image-20200708143707269"></p>
</li>
<li><p>重新使用 <code>vagrant up</code> 启动机器即可。然后再 <code>vagrant ssh</code> 连接机器</p>
</li>
</ul>
</li>
<li><p>默认只允许 ssh 登录方式，为了后来操作方便，文件上传等，我们可以配置允许账号密码登录</p>
<pre><code>Vagrant ssh 进去系统之后

vi /etc/ssh/sshd_config

修改 PasswordAuthentication yes/no

重启服务 service sshd restart</code></pre>
</li>
<li><p>以后可以使用提供的 ssh 连接工具直接连接</p>
</li>
</ul>
<h3 id="3、下载安装-Centos7"><a href="#3、下载安装-Centos7" class="headerlink" title="3、下载安装 Centos7"></a>3、下载安装 <a target="_blank" rel="noopener" href="https://mirrors.aliyun.com/centos/7.8.2003/isos/x86_64/">Centos7</a></h3><blockquote>
<p>阿里云镜像下载地址  <a target="_blank" rel="noopener" href="https://mirrors.aliyun.com/centos/7.8.2003/isos/x86_64/">https://mirrors.aliyun.com/centos/7.8.2003/isos/x86_64/</a></p>
</blockquote>
<h4 id="配置仓库"><a href="#配置仓库" class="headerlink" title="配置仓库#"></a>配置仓库<a target="_blank" rel="noopener" href="https://www.cnblogs.com/wozixiaoyao/p/13378841.html#1002060005">#</a></h4><p>1）备份</p>
<pre><code>mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup</code></pre>
<p>2）下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/</p>
<pre><code>wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo</code></pre>
<p>3）运行 yum makecache 生成缓存</p>
<blockquote>
<p>参考阿里云Centos镜像配置</p>
<p><a target="_blank" rel="noopener" href="https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11lumMFr">https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11lumMFr</a></p>
</blockquote>
<h4 id="配置-ssh"><a href="#配置-ssh" class="headerlink" title="配置 ssh"></a>配置 ssh</h4><p>1）查看是否安装了ssh</p>
<pre class=" language-sh"><code class="language-sh">yum list installed | grep openssh-server</code></pre>
<p>2）安装ssh</p>
<pre class=" language-sh"><code class="language-sh">yum install openssh-server</code></pre>
<p>3）修改ssh配置</p>
<pre class=" language-sh"><code class="language-sh">sudo vim /etc/ssh/ssh_config </code></pre>
<p>将文件中，关于监听端口、监听地址前的 # 号去除</p>
<p><a target="_blank" rel="noopener" href="https://gitee.com/jinxin.70/oss/raw/master/uPic2/image-20200726091401137.png"><img src="https://gitee.com/jinxin.70/oss/raw/master/uPic2/image-20200726091401137.png" alt="image-20200726091401137"></a></p>
<p>开启允许远程登录</p>
<p><img src="%E9%A1%B9%E7%9B%AE%E8%83%8C%E6%99%AF.assets/image-20200809174146707.png" alt="image-20200809174146707"></p>
<p>开启使用用户名密码来作为连接验证</p>
<p><img src="%E9%A1%B9%E7%9B%AE%E8%83%8C%E6%99%AF.assets/image-20200809174337162.png" alt="image-20200809174337162"></p>
<p>4）启动sshd服务</p>
<pre class=" language-sh"><code class="language-sh">sudo service sshd start</code></pre>
<p>5）检查 sshd 服务是否已经开启</p>
<pre class=" language-sh"><code class="language-sh">ps -e | grep sshd</code></pre>
<p>或者检查 <strong>22</strong> 号端口是否开启监听</p>
<pre class=" language-sh"><code class="language-sh">netstat -an | grep 22</code></pre>
<p>6）开启开机自启动</p>
<pre class=" language-sh"><code class="language-sh">sudo systemctl enable sshd</code></pre>
<p>7）检查是否加入了开机自启动</p>
<pre class=" language-sh"><code class="language-sh">systemctl list-unit-files | grep sshd</code></pre>
<h2 id="2、安装-docker"><a href="#2、安装-docker" class="headerlink" title="2、安装 docker"></a>2、安装 docker</h2><h3 id="1、卸载旧版本"><a href="#1、卸载旧版本" class="headerlink" title="1、卸载旧版本"></a>1、卸载旧版本</h3><pre class=" language-sh"><code class="language-sh">sudo yum remove docker \
              docker-client \
              docker-client-latest \
              docker-common \
              docker-latest \
              docker-latest-logrotate \
              docker-logrotate \
              docker-engine</code></pre>
<h3 id="2、安装-yum-utils-软件包-并设置稳定的存储库。"><a href="#2、安装-yum-utils-软件包-并设置稳定的存储库。" class="headerlink" title="2、安装 yum-utils 软件包, 并设置稳定的存储库。"></a>2、安装 yum-utils 软件包, 并设置稳定的存储库。</h3><pre class=" language-sh"><code class="language-sh">sudo yum install -y yum-utils

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo</code></pre>
<h3 id="3、安装最新版本的-docker-引擎-Docker-Engine-和容器"><a href="#3、安装最新版本的-docker-引擎-Docker-Engine-和容器" class="headerlink" title="3、安装最新版本的 docker 引擎(Docker Engine ) 和容器"></a>3、安装最新版本的 docker 引擎(Docker Engine ) 和容器</h3><pre class=" language-sh"><code class="language-sh">sudo yum install docker-ce docker-ce-cli containerd.io</code></pre>
<h3 id="4、启动-Docker"><a href="#4、启动-Docker" class="headerlink" title="4、启动 Docker"></a>4、启动 Docker</h3><pre class=" language-sh"><code class="language-sh">sudo systemctl start docker</code></pre>
<h3 id="5、Docker-开机自启"><a href="#5、Docker-开机自启" class="headerlink" title="5、Docker 开机自启"></a>5、Docker 开机自启</h3><pre class=" language-sh"><code class="language-sh">systemctl enable docker</code></pre>
<h3 id="6、检查镜像"><a href="#6、检查镜像" class="headerlink" title="6、检查镜像"></a>6、检查镜像</h3><pre class=" language-sh"><code class="language-sh"># 检查镜像
docker images

# 检查容器
docker ps

# 检查开启的容器
docker ps -a</code></pre>
<h3 id="7、-容器镜像加速"><a href="#7、-容器镜像加速" class="headerlink" title="7、 容器镜像加速"></a>7、 容器镜像加速</h3><blockquote>
<p>CentOS 配置阿里云镜像加速器, 您可以通过修改 daemon 配置文件  /etc/docker/daemon.json  来使用加速器</p>
</blockquote>
<pre class=" language-sh"><code class="language-sh">//1、 
sudo mkdir -p /etc/docker

//2、 阿里云镜像加载
sudo tee /etc/docker/daemon.json <<-'EOF'
&#123;
  "registry-mirrors": ["https://fivh4y6i.mirror.aliyuncs.com"]
&#125;
EOF

//3、更新镜像加载
sudo systemctl daemon-reload

//4、重启 docker
sudo systemctl restart docker</code></pre>
<h2 id="3、docker-安装-mysql"><a href="#3、docker-安装-mysql" class="headerlink" title="3、docker 安装 mysql"></a>3、docker 安装 mysql</h2><h3 id="1、下载-mysql-镜像"><a href="#1、下载-mysql-镜像" class="headerlink" title="1、下载 mysql 镜像"></a>1、下载 mysql 镜像</h3><pre class=" language-sh"><code class="language-sh">docker pull mysql:5.7</code></pre>
<h3 id="2、启动容器"><a href="#2、启动容器" class="headerlink" title="2、启动容器"></a>2、启动容器</h3><pre class=" language-sh"><code class="language-sh">docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7</code></pre>
<h3 id="3、修改配置文件-my-cnf"><a href="#3、修改配置文件-my-cnf" class="headerlink" title="3、修改配置文件 my.cnf"></a>3、修改配置文件 my.cnf</h3><pre class=" language-sh"><code class="language-sh">vi /mydata/mysql/conf/my.cnf</code></pre>
<pre class=" language-sh"><code class="language-sh">[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve</code></pre>
<h3 id="4、重启"><a href="#4、重启" class="headerlink" title="4、重启"></a>4、重启</h3><pre class=" language-sh"><code class="language-sh">docker restart mysql</code></pre>
<h3 id="5、进入-mysql-容器"><a href="#5、进入-mysql-容器" class="headerlink" title="5、进入 mysql 容器"></a>5、进入 mysql 容器</h3><pre class=" language-sh"><code class="language-sh">docker exec -it mysql /bin/bash</code></pre>
<h3 id="6、查看是否修改成功"><a href="#6、查看是否修改成功" class="headerlink" title="6、查看是否修改成功"></a>6、查看是否修改成功</h3><pre><code>cat /etc/mysql/my.cnf</code></pre>
<h3 id="7、设置-MySQL-开机自启"><a href="#7、设置-MySQL-开机自启" class="headerlink" title="7、设置 MySQL 开机自启"></a>7、设置 MySQL 开机自启</h3><pre class=" language-sh"><code class="language-sh">docker update mysql --restart=always</code></pre>
<h2 id="4、docker-安装-redis"><a href="#4、docker-安装-redis" class="headerlink" title="4、docker 安装 redis"></a>4、docker 安装 redis</h2><h3 id="1、下载-redis-镜像"><a href="#1、下载-redis-镜像" class="headerlink" title="1、下载 redis 镜像"></a>1、下载 redis 镜像</h3><pre class=" language-sh"><code class="language-sh">docker pull redis</code></pre>
<h3 id="2、创建配置文件"><a href="#2、创建配置文件" class="headerlink" title="2、创建配置文件"></a>2、创建配置文件</h3><pre class=" language-sh"><code class="language-sh">mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf</code></pre>
<h3 id="3、启动容器"><a href="#3、启动容器" class="headerlink" title="3、启动容器"></a>3、启动容器</h3><pre class=" language-sh"><code class="language-sh">docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf</code></pre>
<h3 id="4、运行-redis"><a href="#4、运行-redis" class="headerlink" title="4、运行 redis"></a>4、运行 redis</h3><pre class=" language-sh"><code class="language-sh">docker exec -it redis redis-cli</code></pre>
<h3 id="5、开启-aof-持久化"><a href="#5、开启-aof-持久化" class="headerlink" title="5、开启 aof 持久化"></a>5、开启 aof 持久化</h3><pre class=" language-sh"><code class="language-sh">vi /mydata/redis/conf/redis.conf</code></pre>
<h3 id="6、持久化"><a href="#6、持久化" class="headerlink" title="6、持久化"></a>6、持久化</h3><pre><code>appendonly yes</code></pre>
<h3 id="7、重启-redis"><a href="#7、重启-redis" class="headerlink" title="7、重启 redis"></a>7、重启 redis</h3><pre><code>docker restart redis</code></pre>
<h3 id="8、设置-redis-开机自启"><a href="#8、设置-redis-开机自启" class="headerlink" title="8、设置 redis 开机自启"></a>8、设置 redis 开机自启</h3><pre class=" language-sh"><code class="language-sh">docker update redis --restart=always</code></pre>
<h2 id="3-amp-4、docker-compose-安装"><a href="#3-amp-4、docker-compose-安装" class="headerlink" title="3&amp;4、docker-compose 安装"></a>3&amp;4、docker-compose 安装</h2><h3 id="1、docker-compose-yml"><a href="#1、docker-compose-yml" class="headerlink" title="1、docker-compose.yml"></a>1、docker-compose.yml</h3><pre class=" language-yml"><code class="language-yml">version: '3.1'
services:
  mysql:  # 服务的名称
    restart: always  # 代表只要 docker 启动，那么这个容器就跟着一起启动
    image: daocloud.io/library/mysql:5.7 #指定镜像路径
    container_name: mysql  # 指定容器名称
    ports:
      - 3306:3306  # 指定端口号的映射
    environment:
      MYSQL_ROOT_PASSWORD: root # 指定 MySQL 的 ROOT 用户登录密码
      TZ: Asia/Shanghai          # 指定时区
    volumes:
      - /mydata/mysql/log:/var/log/mysql
      - /mydata/mysql/data:/var/lib/mysql # 映射数据卷 
      - /mydata/mysql/conf:/etc/mysql

  redis:
       restart: always  # 代表只要 docker 启动，那么这个容器就跟着一起启动
    image: daocloud.io/library/redis:latest #指定镜像路径
    container_name: redis
    ports:
      - 6079:6079
    environment:
      TZ: Asia/Shanghai          # 指定时区
    volumes:
      - /mydata/redis/data:/data
      - /mydata/redis/conf:/etc/redis</code></pre>
<h3 id="2、安装"><a href="#2、安装" class="headerlink" title="2、安装"></a>2、安装</h3><pre class=" language-sh"><code class="language-sh">//在 /mydata 目录下执行
docker-compose up -d

//开启|关闭|重启已经存在的由 docker-compose 维护的容器
docker-compose start|stop|restart

//关闭并删除容器
docker-compose down

//查看日志
docker-compose logs -f</code></pre>
<h3 id="3、配置-MySQL-编码"><a href="#3、配置-MySQL-编码" class="headerlink" title="3、配置 MySQL 编码"></a>3、配置 MySQL 编码</h3><pre class=" language-sh"><code class="language-sh">$ vim /mydata/mysql/conf/my.cnf
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve</code></pre>
<h3 id="4、增加-Redis-持久化"><a href="#4、增加-Redis-持久化" class="headerlink" title="4、增加 Redis 持久化"></a>4、增加 Redis 持久化</h3><pre class=" language-sh"><code class="language-sh">$ vim /mydata/redis/conf/redis.conf
# appendonly yes</code></pre>
<h3 id="5、Redis-开机重启"><a href="#5、Redis-开机重启" class="headerlink" title="5、Redis 开机重启"></a>5、Redis 开机重启</h3><pre class=" language-sh"><code class="language-sh">$ docker-compose stop
$ docker-compose up -d</code></pre>
<h2 id="5、开发环境统一"><a href="#5、开发环境统一" class="headerlink" title="5、开发环境统一"></a>5、开发环境统一</h2><h3 id="1、maven"><a href="#1、maven" class="headerlink" title="1、maven"></a>1、maven</h3><blockquote>
<p>配置阿里云镜像</p>
</blockquote>
<pre class=" language-xml"><code class="language-xml"><span class="token comment" spellcheck="true">&lt;!-- 阿里云仓库--></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mirror</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>id</span><span class="token punctuation">></span></span>nexus-aliyun<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>id</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>mirrorOf</span><span class="token punctuation">></span></span>central<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mirrorOf</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">></span></span>Nexus aliyun<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>url</span><span class="token punctuation">></span></span>http://maven.aliyun.com/nexus/content/groups/public<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>url</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>mirror</span><span class="token punctuation">></span></span> </code></pre>
<blockquote>
<p>配置 jdk1.8 编译项目</p>
</blockquote>
<pre class=" language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>profiles</span><span class="token punctuation">></span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>profile</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span>   <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>id</span><span class="token punctuation">></span></span>jdk‐1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>id</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span>   <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>activation</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span>   <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>activeByDefault</span><span class="token punctuation">></span></span>true<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>activeByDefault</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span>   <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>jdk</span><span class="token punctuation">></span></span>1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>jdk</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>activation</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>properties</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span>  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.source</span><span class="token punctuation">></span></span>1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.source</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.target</span><span class="token punctuation">></span></span>1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.target</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.compilerVersion</span><span class="token punctuation">></span></span>1.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.compilerVersion</span><span class="token punctuation">></span></span>
<span class="token entity" title="&nbsp;">&amp;nbsp;</span><span class="token entity" title="&nbsp;">&amp;nbsp;</span>  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>properties</span><span class="token punctuation">></span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>profile</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>profiles</span><span class="token punctuation">></span></span></code></pre>
<h3 id="2、IDEA-amp-VsCode"><a href="#2、IDEA-amp-VsCode" class="headerlink" title="2、IDEA&amp;VsCode"></a>2、IDEA&amp;VsCode</h3><pre class=" language-txt"><code class="language-txt">IDEA 安装 lombok 、 mybatisx 插件</code></pre>
<blockquote>
<p>VsCode 安装插件</p>
</blockquote>
<p><img src="C:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images\image-20200803181937301.png" alt="image-20200803181937301"></p>
<p><img src="C:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images\image-20200803182211440.png" alt="image-20200803182211440"></p>
<p><img src="C:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images\image-20200803182406782.png" alt="image-20200803182406782"></p>
<h3 id="3、安装-git"><a href="#3、安装-git" class="headerlink" title="3、安装 git"></a>3、安装 git</h3><h4 id="1、配置-Git"><a href="#1、配置-Git" class="headerlink" title="1、配置 Git"></a>1、配置 Git</h4><pre class=" language-sh"><code class="language-sh">git config --global user.name "guoxiaolong"
git config --global user.emall "18240885452@163.com"</code></pre>
<h4 id="2、密钥配置"><a href="#2、密钥配置" class="headerlink" title="2、密钥配置"></a>2、密钥配置</h4><pre class=" language-sh"><code class="language-sh">ssh-keygen -t rsa -C "18240885452@163.com"</code></pre>
<h4 id="3、查看密钥"><a href="#3、查看密钥" class="headerlink" title="3、查看密钥"></a>3、查看密钥</h4><pre class=" language-sh"><code class="language-sh">cat ~/.ssh/id_rsa.pub</code></pre>
<h4 id="4、检查配置成功？"><a href="#4、检查配置成功？" class="headerlink" title="4、检查配置成功？"></a>4、检查配置成功？</h4><pre class=" language-sh"><code class="language-sh">ssh -T git@gitee.com</code></pre>
<h4 id="5、显示则成功"><a href="#5、显示则成功" class="headerlink" title="5、显示则成功"></a>5、显示则成功</h4><pre class=" language-sh"><code class="language-sh">“ You've successfully authenticated。”</code></pre>
<h3 id="4、逆向工程使用"><a href="#4、逆向工程使用" class="headerlink" title="4、逆向工程使用"></a>4、逆向工程使用</h3><ul>
<li>导入项目逆向工程</li>
<li>下载开源后台管理系统脚手架工程<ul>
<li>导入工程，创建数据库</li>
<li>修改工程 shiro 依赖 SpringSecurity</li>
<li>删除部分暂时不需要的业务</li>
</ul>
</li>
<li>下载开源后台管理系统 vue 端脚手架工程<ul>
<li>vscode 导入前端项目</li>
<li>前后端联调测试基本功能</li>
</ul>
</li>
</ul>
<h3 id="5、创建项目微服务"><a href="#5、创建项目微服务" class="headerlink" title="5、创建项目微服务"></a>5、创建项目微服务</h3><p>商品服务、仓储服务、订单服务、优惠券服务、用户服务</p>
<p>1)、从 gitee 初始化一个项目</p>
<p>2）、创建各个微服务项目</p>
<h2 id="四、快速开发"><a href="#四、快速开发" class="headerlink" title="四、快速开发"></a>四、快速开发</h2><h3 id="1、搭建后台管理系统"><a href="#1、搭建后台管理系统" class="headerlink" title="1、搭建后台管理系统"></a>1、搭建后台管理系统</h3><p>使用人人开源（<a target="_blank" rel="noopener" href="https://gitee.com/renrenio%EF%BC%89%E7%9A%84%E8%84%9A%E6%89%8B%E6%9E%B6%E5%BF%AB%E9%80%9F%E6%90%AD%E5%BB%BA%E5%90%8E%E5%8F%B0%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F">https://gitee.com/renrenio）的脚手架快速搭建后台管理系统</a></p>
<ol>
<li>脚手架 renren-fast ：后台管理系统后端项目</li>
<li>脚手架 renren-fast-vue ：后台管理系统前端项目</li>
</ol>
<h3 id="2、逆向工程搭建基本代码"><a href="#2、逆向工程搭建基本代码" class="headerlink" title="2、逆向工程搭建基本代码"></a>2、逆向工程搭建基本代码</h3><p>使用人人开源的逆向工程项目（<a target="_blank" rel="noopener" href="https://gitee.com/renrenio/renren-generator">renren-generator</a>），根据数据库表结构生成每个微服务的基本代码：entity、xml、dao、service 代码</p>
<h3 id="3、配置-amp-测试微服务CRUD功能"><a href="#3、配置-amp-测试微服务CRUD功能" class="headerlink" title="3、配置&amp;测试微服务CRUD功能"></a>3、配置&amp;测试微服务CRUD功能</h3><pre class=" language-yaml"><code class="language-yaml"><span class="token key atrule">spring</span><span class="token punctuation">:</span>

  <span class="token key atrule">application</span><span class="token punctuation">:</span>

    <span class="token key atrule">name</span><span class="token punctuation">:</span> gulimall<span class="token punctuation">-</span>coupon

  <span class="token key atrule">datasource</span><span class="token punctuation">:</span>

    <span class="token key atrule">url</span><span class="token punctuation">:</span> jdbc<span class="token punctuation">:</span>mysql<span class="token punctuation">:</span>//127.0.0.1<span class="token punctuation">:</span>3306/gulimall_sms<span class="token punctuation">?</span>useUnicode=true<span class="token important">&amp;characterEncoding</span>=UTF<span class="token punctuation">-</span>8<span class="token important">&amp;useSSL</span>=false<span class="token important">&amp;serverTimezone</span>=Asia/Shanghai

    <span class="token key atrule">driver-class-name</span><span class="token punctuation">:</span> com.mysql.jdbc.Driver

    <span class="token key atrule">username</span><span class="token punctuation">:</span> root

    <span class="token key atrule">password</span><span class="token punctuation">:</span> <span class="token number">123456</span>

  <span class="token key atrule">jackson</span><span class="token punctuation">:</span>

    <span class="token key atrule">date-format</span><span class="token punctuation">:</span> yyyy<span class="token punctuation">-</span>MM<span class="token punctuation">-</span>dd HH<span class="token punctuation">:</span>mm<span class="token punctuation">:</span>ss

<span class="token key atrule">mybatis-plus</span><span class="token punctuation">:</span>

  <span class="token key atrule">mapper-locations</span><span class="token punctuation">:</span> classpath<span class="token punctuation">:</span>/mapper/**/*.xml

  <span class="token key atrule">global-config</span><span class="token punctuation">:</span>

    <span class="token key atrule">db-config</span><span class="token punctuation">:</span>

      <span class="token key atrule">id-type</span><span class="token punctuation">:</span> auto

      <span class="token key atrule">logic-delete-value</span><span class="token punctuation">:</span> <span class="token number">1</span>

      <span class="token key atrule">logic-not-delete-value</span><span class="token punctuation">:</span> <span class="token number">0</span>

<span class="token key atrule">server</span><span class="token punctuation">:</span>

  <span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">3000</span>

<span class="token key atrule">logging</span><span class="token punctuation">:</span>

  <span class="token key atrule">level</span><span class="token punctuation">:</span>

    <span class="token key atrule">com.atguigu.gulimall</span><span class="token punctuation">:</span> debug</code></pre>
<h2 id="五、分布式组件"><a href="#五、分布式组件" class="headerlink" title="五、分布式组件"></a>五、分布式组件</h2><h3 id="1、SpringCloud-Alibaba-简介"><a href="#1、SpringCloud-Alibaba-简介" class="headerlink" title="1、SpringCloud Alibaba 简介"></a>1、SpringCloud Alibaba 简介</h3><h4 id="1）简介"><a href="#1）简介" class="headerlink" title="1）简介"></a>1）简介</h4><p>Spring Cloud Alibaba 致力于提供微服务开发的一站式解决方案。此项目包含开发分布式应用微服务的必需组件，方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来开发分布式应用服务。</p>
<p>依托 Spring Cloud Alibaba，您只需要添加一些注解和少量配置，就可以将 Spring Cloud 应用接入阿里微服务解决方案，通过阿里中间件来迅速搭建分布式应用系统。</p>
<p><a target="_blank" rel="noopener" href="https://github.com/alibaba/spring-cloud-alibaba">https://github.com/alibaba/spring-cloud-alibaba</a></p>
<h4 id="2）为什么用"><a href="#2）为什么用" class="headerlink" title="2）为什么用"></a>2）为什么用</h4><p>Spring Cloud 的几大痛点：</p>
<ol>
<li>Spring Cloud 部分组件停止维护和更新，给开发带来不便</li>
<li>Spring Cloud 部分环境搭建复杂，没有完善的可视化界面，我们需要大量的二次开发和定制</li>
<li>Spring Cloud 配置复杂，难以上手，部分配置差别难以区分和合理应用</li>
</ol>
<p>Spring Cloud Alibaba 的优势：</p>
<ol>
<li>阿里使用过的组件经历了考验，性能强悍，设计合理，现在开源出来大家用</li>
<li>成套的产品搭配完善的可视化界面给开发运维带来极大的便利</li>
<li>搭建简单，学习曲线低</li>
</ol>
<h4 id="3）最终的技术搭配方案"><a href="#3）最终的技术搭配方案" class="headerlink" title="3）最终的技术搭配方案"></a>3）最终的技术搭配方案</h4><ol>
<li>Spring Cloud Alibaba - Nacos：注册中心 (服务发现/注册)</li>
<li>Spring Cloud Alibaba Nacos：配置中心 (动态配置管理)</li>
<li>Spring Cloud - Ribbon：负载均衡</li>
<li>Spring Cloud - Feign：声明式 HTTP 客户端 (调用远程服务)</li>
<li>Spring Cloud Alibaba - Sentinel：服务容错 (限流、降级、熔断)</li>
<li>Spring Cloud - Gateway：API 网关 (weblux编程模式)</li>
<li>Spring Cloud - Sleuth：调用链监控</li>
<li>Spring Cloud Alibaba - Seata：原 Fescar ，即分布式事务解决方案</li>
</ol>
<h4 id="4）版本选择"><a href="#4）版本选择" class="headerlink" title="4）版本选择"></a>4）版本选择</h4><p>由于 Spring Boot 1 和 Spring Boot 2 在 Actuator 模块的接口和注解有很大的变更，且 spring-cloud-commons 从 1.x.x 版本升级到 2.0.0 版本也有较大的变更，因此我们采取跟 Spring Boot 版本号一致的版本：</p>
<ul>
<li>1.5.x 版本适用于 Spring Boot 1.5.x</li>
<li>2.0.x 版本适用于 Spring Boot 2.0.x</li>
<li>2.1.x 版本适用于 Spring Boot 2.1.x</li>
</ul>
<h3 id="2、SpringCloud-Alibaba-Nacos-注册中心"><a href="#2、SpringCloud-Alibaba-Nacos-注册中心" class="headerlink" title="2、SpringCloud Alibaba Nacos 注册中心"></a>2、SpringCloud Alibaba Nacos 注册中心</h3><p>Nacos 是阿里巴巴开源的一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。他是使用 java 编写，需要依赖 java 环境。</p>
<p>Nacos 文档地址： <a target="_blank" rel="noopener" href="https://nacos.io/zh-cn/docs/quick-start.html">https://nacos.io/zh-cn/docs/quick-start.html</a></p>
<h4 id="1）引入依赖"><a href="#1）引入依赖" class="headerlink" title="1）引入依赖"></a>1）引入依赖</h4><pre class=" language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">></span></span>com.alibaba.cloud<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">></span></span>spring-cloud-starter-alibaba-nacos-discovery<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">></span></span></code></pre>
<h4 id="2）Nacos-Server-启动"><a href="#2）Nacos-Server-启动" class="headerlink" title="2）Nacos Server 启动"></a>2）Nacos Server 启动</h4><p>具体参考官网：<a target="_blank" rel="noopener" href="https://nacos.io/zh-cn/docs/quick-start.html">https://nacos.io/zh-cn/docs/quick-start.html</a></p>
<p>Nacos Server 启动后，进入 <a target="_blank" rel="noopener" href="http://localhost:8848/">http://localhost:8848</a> 查看控制台 (默认账号名/密码为 nacos/nacos)</p>
<p>关于更多的 Nacos Server 版本，可以从 <a target="_blank" rel="noopener" href="https://github.com/alibaba/nacos/releases">release 页面</a> 下载最新的版本</p>
<h4 id="3）Nacos-基本配置"><a href="#3）Nacos-基本配置" class="headerlink" title="3）Nacos 基本配置"></a>3）Nacos 基本配置</h4><pre class=" language-properties"><code class="language-properties"><span class="token attr-name">server.port</span><span class="token punctuation">=</span><span class="token attr-value">8081</span>

<span class="token attr-name">spring.application.name</span><span class="token punctuation">=</span><span class="token attr-value">nacos-provider</span>

<span class="token attr-name">spring.cloud.nacos.discovery.server-addr</span><span class="token punctuation">=</span><span class="token attr-value">127.0.0.1:8848</span>

<span class="token attr-name">management.endpoints.web.exposure.include</span><span class="token punctuation">=</span><span class="token attr-value">*</span></code></pre>
<p>如果不想使用 Nacos 作为您的服务注册与发现，可以将 <code>spring.cloud.nacos.discovery</code> 设置为 <code>false</code>。</p>
<p>使用 <code>@EnableDiscoveryClient</code> 注解开启服务注册与发现功能</p>
<pre class=" language-java"><code class="language-java"><span class="token annotation punctuation">@SpringBootApplication</span>

<span class="token annotation punctuation">@EnableDiscoveryClient</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">CouponApplication</span> <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span>String<span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>

        SpringApplication<span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span>CouponApplication<span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> args<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span>

<span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<h4 id="4）启动应用"><a href="#4）启动应用" class="headerlink" title="4）启动应用"></a>4）启动应用</h4><p>观察 Nacos 控制台 服务列表是否已经注册上服务</p>
<p>注意：每一个应用都应该有名字，这样才能注册上去。修改 application.properties 文件</p>
<pre class=" language-properties"><code class="language-properties"><span class="token attr-name">spring.application.name</span><span class="token punctuation">=</span><span class="token attr-value">service-provider</span>

<span class="token attr-name">server.port</span><span class="token punctuation">=</span><span class="token attr-value">8000</span></code></pre>
<h3 id="3、SpringCloud-OpenFeign-声明式远程调用"><a href="#3、SpringCloud-OpenFeign-声明式远程调用" class="headerlink" title="3、SpringCloud OpenFeign 声明式远程调用"></a>3、SpringCloud OpenFeign 声明式远程调用</h3><h4 id="1）简介-1"><a href="#1）简介-1" class="headerlink" title="1）简介"></a>1）简介</h4><p>Feign 是一个声明式的 HTTP 客户端，它的目的就是让远程调用更加简单。Feign 提供了 HTTP 请求的模板，通过编写简单的接口和插入注解，就可以定义好 HTTP 请求的参数、格式、地址等信息。</p>
<p>Feign 整合了 Ribbon (负载均衡) 和 Hystrix (服务熔断)，可以让我们不再需要显式地使用这两个组件。</p>
<p>Spring Cloud Feign 在 Netfix Feign 的基础上扩展了对 SpringMVC 注解的支持，在其实现下，我们只需创建一个接口并用注解的方式来配置它，即可完成对服务提供方的接口绑定。简化了 Spring Cloud Ribbon 自行封装服务调用客户端的开发量。</p>
<h4 id="2）使用"><a href="#2）使用" class="headerlink" title="2）使用"></a>2）使用</h4><p>1、引入依赖</p>
<pre class=" language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">></span></span>org.springframework.cloud<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">></span></span>spring-cloud-starter-openfeign<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">></span></span></code></pre>
<p>2、开启 feign 功能</p>
<pre class=" language-java"><code class="language-java"><span class="token annotation punctuation">@SpringBootApplication</span>

<span class="token annotation punctuation">@EnableDiscoveryClient</span>

<span class="token annotation punctuation">@EnableFeignClients</span><span class="token punctuation">(</span>basePackages <span class="token operator">=</span> <span class="token string">"com.atguigu.gulimall.member.feign"</span><span class="token punctuation">)</span></code></pre>
<p>3、 编写一个接口，告诉 Spring Cloud 这个接口需要调用远程服务</p>
<p>声明接口的每一个方法都是调用哪个远程服务的那个请求</p>
<pre class=" language-java"><code class="language-java"><span class="token annotation punctuation">@FeignClient</span><span class="token punctuation">(</span><span class="token string">"gulimall-coupon"</span><span class="token punctuation">)</span>

<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">CouponFeignService</span> <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>

    <span class="token comment" spellcheck="true">/**

    * 远程调用的路径写全

    *

    * @return &amp;#123;@link R&amp;#125;

    */</span>

    <span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">"/coupon/coupon/member/list"</span><span class="token punctuation">)</span>

    <span class="token keyword">public</span> R <span class="token function">memberCoupons</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<p>4、编写 controller</p>
<pre class=" language-java"><code class="language-java">    <span class="token annotation punctuation">@Autowired</span>

    <span class="token keyword">private</span> CouponFeignService couponFeignService<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">"/coupons"</span><span class="token punctuation">)</span>

    <span class="token keyword">public</span> R <span class="token function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>

        MemberEntity memberEntity <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MemberEntity</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        memberEntity<span class="token punctuation">.</span><span class="token function">setNickname</span><span class="token punctuation">(</span><span class="token string">"don"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        R memberCoupons <span class="token operator">=</span> couponFeignService<span class="token punctuation">.</span><span class="token function">memberCoupons</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword">return</span> R<span class="token punctuation">.</span><span class="token function">ok</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"member"</span><span class="token punctuation">,</span> memberEntity<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"coupons"</span><span class="token punctuation">,</span> memberCoupons<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">"test"</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<p>5、远程服务编写</p>
<pre class=" language-java"><code class="language-java"><span class="token annotation punctuation">@RestController</span>

<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">"coupon/coupon"</span><span class="token punctuation">)</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">CouponController</span> <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>

    <span class="token annotation punctuation">@Autowired</span>

    <span class="token keyword">private</span> CouponService couponService<span class="token punctuation">;</span>

    <span class="token comment" spellcheck="true">/**

    * 会员优惠券  测试

    *

    * @return &amp;#123;@link R&amp;#125;

    */</span>

    <span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">"/member/list"</span><span class="token punctuation">)</span>

    <span class="token keyword">public</span> R <span class="token function">memberCoupons</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>

        <span class="token keyword">return</span> R<span class="token punctuation">.</span><span class="token function">ok</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">"test"</span><span class="token punctuation">,</span> <span class="token string">"ok"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span>

<span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<p>6、启动两个服务测试</p>
<p>访问 <a target="_blank" rel="noopener" href="http://localhost:4000/member/member/coupons">http://localhost:4000/member/member/coupons</a></p>
<p>成功返回 json</p>
<pre class=" language-json"><code class="language-json">&amp;#<span class="token number">123</span><span class="token punctuation">;</span>

<span class="token property">"msg"</span><span class="token operator">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>

<span class="token property">"code"</span><span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>

<span class="token property">"coupons"</span><span class="token operator">:</span> <span class="token string">"ok"</span><span class="token punctuation">,</span>

<span class="token property">"member"</span><span class="token operator">:</span> &amp;#<span class="token number">123</span><span class="token punctuation">;</span>

<span class="token property">"id"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"levelId"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"username"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"password"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"nickname"</span><span class="token operator">:</span> <span class="token string">"don"</span><span class="token punctuation">,</span>

<span class="token property">"mobile"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"email"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"header"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"gender"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"birth"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"city"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"job"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"sign"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"sourceType"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"integration"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"growth"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"status"</span><span class="token operator">:</span> <span class="token null">null</span><span class="token punctuation">,</span>

<span class="token property">"createTime"</span><span class="token operator">:</span> <span class="token null">null</span>

&amp;#<span class="token number">125</span><span class="token punctuation">;</span>

&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<h3 id="4、SpringCloud-Alibaba-Nacos-配置中心"><a href="#4、SpringCloud-Alibaba-Nacos-配置中心" class="headerlink" title="4、SpringCloud Alibaba Nacos 配置中心"></a>4、SpringCloud Alibaba Nacos 配置中心</h3><h4 id="1）引入依赖-1"><a href="#1）引入依赖-1" class="headerlink" title="1）引入依赖"></a>1）引入依赖</h4><pre class=" language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">></span></span>com.alibaba.cloud<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">></span></span>spring-cloud-starter-alibaba-nacos-config<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">></span></span></code></pre>
<h4 id="2）配置文件中配置"><a href="#2）配置文件中配置" class="headerlink" title="2）配置文件中配置"></a>2）配置文件中配置</h4><p>在应用的 <code>/src/main/resources/bootstrap.properties</code> 配置文件中配置 Nacos Config 元数据</p>
<pre class=" language-properties"><code class="language-properties"><span class="token attr-name">spring.application.name</span><span class="token punctuation">=</span><span class="token attr-value">nacos-config-example</span>

<span class="token attr-name">spring.cloud.nacos.config.server-addr</span><span class="token punctuation">=</span><span class="token attr-value">127.0.0.1:8848</span></code></pre>
<h4 id="3）Nacos-控制台配置"><a href="#3）Nacos-控制台配置" class="headerlink" title="3）Nacos 控制台配置"></a>3）Nacos 控制台配置</h4><p>添加的配置的详情如下</p>
<pre class=" language-java"><code class="language-java">dataId 为 gulimall<span class="token operator">-</span>coupon<span class="token punctuation">.</span>properties    <span class="token comment" spellcheck="true">//默认规则，应用名.properties</span>

group  为 DEFAULT_GROUP

内容如下

user<span class="token punctuation">.</span>id<span class="token operator">=</span><span class="token number">1</span>

user<span class="token punctuation">.</span>name<span class="token operator">=</span>don

user<span class="token punctuation">.</span>age<span class="token operator">=</span><span class="token number">17</span></code></pre>
<h4 id="4）启动应用-1"><a href="#4）启动应用-1" class="headerlink" title="4）启动应用"></a>4）启动应用</h4><p>应用会从 Nacos Config 中获取相应的配置，并添加在 Spring Environment 的 PropertySources 中。这里我们使用 <code>@Value</code> 注解来将对应的配置注入到 SampleController 的 userName 和 age 字段，并添加 <code>@RefreshScope</code> 打开动态刷新功能</p>
<pre class=" language-java"><code class="language-java"><span class="token annotation punctuation">@RefreshScope</span>：动态获取并刷新配置

<span class="token annotation punctuation">@Value</span><span class="token punctuation">(</span><span class="token string">"$&amp;#123;配置项的名&amp;#125;"</span><span class="token punctuation">)</span>：获取到配置，如果配置中心和当前应用的配置文件中都配置了相同的项，优先使用配置中心的配置</code></pre>
<h4 id="5）配置中心-命名空间"><a href="#5）配置中心-命名空间" class="headerlink" title="5）配置中心-命名空间"></a>5）配置中心-命名空间</h4><p>用于进行租户粒度的配置隔离。不同的命名空间下，可以存在相同的 Group 或 Data ID 的配置。Namespace 的常用场景之一是不同环境的配置的区分隔离，例如开发测试环境和生产环境的资源(如配置、服务)隔离等。</p>
<pre class=" language-java"><code class="language-java"><span class="token comment" spellcheck="true">/**

* 默认：public(保留空间)；默认新增的所有配置都在public空间。

* 1、开发，测试，生产：利用命名空间来做环境隔离。

* 注意：在bootstrap.properties；配置上，需要使用哪个命名空间下的配置，

* spring.cloud.nacos.config.namespace=9de62e44-cd2a-4a82-bf5c-95878bd5e871

* 2、每一个微服务之间互相隔离配置，每一个微服务都创建自己的命名空间，只加载自己命名空间下的所有配置

*/</span></code></pre>
<h4 id="6）配置中心-配置集"><a href="#6）配置中心-配置集" class="headerlink" title="6）配置中心-配置集"></a>6）配置中心-配置集</h4><p>一组相关或者不相关的配置项的集合称为配置集。在系统中，一个配置文件通常就是一个配置集，包含了系统各个方面的配置。例如，一个配置集可能包含了数据源、线程池、日志级别等配置项。</p>
<h4 id="7）配置中心-配置集ID"><a href="#7）配置中心-配置集ID" class="headerlink" title="7）配置中心-配置集ID"></a>7）配置中心-配置集ID</h4><p>Nacos 中的某个配置集的 ID。配置集 ID 是组织划分配置的维度之一。 Data lD 通常用于组织划分系统的配置集。一个系统或者应用可以包含多个配置集，每个配置集都可以被一个有意义的名称标识。Data lD 通常采用类 Java 包 ( 如 com.taobao.tc.refund.log.level ) 的命名规则保证全局唯一性。此命名规则非强制。</p>
<h4 id="8）配置中心-配置分组"><a href="#8）配置中心-配置分组" class="headerlink" title="8）配置中心-配置分组"></a>8）配置中心-配置分组</h4><p>Nacos 中的一组配置集，是组织配置的维度之一。通过一个有意义的字符串（如 Buy 或 Trade ）对配置集进行分组，从而区分 Data ID 相同的配置集。当您在 Nacos 上创建一个配置时，如果未填写配置分组的名称，则配置分组的名称默认采用 DEFAULT_GROUP 。配置分组的常见场景：不同的应用或组件使用了相同的配置类型，如 database_url 配置和 MQ_topic 配置。</p>
<p>默认所有的配置集都属于：DEFAULT_GROUP</p>
<blockquote>
<p>该项目中的使用：每个微服务创建自己的命名空间，使用配置分组区分环境，dev，test，prod</p>
</blockquote>
<h4 id="9）配置中心-加载多配置集"><a href="#9）配置中心-加载多配置集" class="headerlink" title="9）配置中心-加载多配置集"></a>9）配置中心-加载多配置集</h4><p>将一个服务的配置文件，拆分成三部分：</p>
<p>1、在 coupon 命名空间下 新建配置</p>
<p>Data ID：datasource.yml</p>
<p>Group：dev</p>
<p>配置格式：YAML</p>
<p>配置内容：</p>
<pre class=" language-yaml"><code class="language-yaml"><span class="token key atrule">spring</span><span class="token punctuation">:</span>

  <span class="token key atrule">datasource</span><span class="token punctuation">:</span>

    <span class="token key atrule">url</span><span class="token punctuation">:</span> jdbc<span class="token punctuation">:</span>mysql<span class="token punctuation">:</span>//127.0.0.1<span class="token punctuation">:</span>3306/gulimall_sms<span class="token punctuation">?</span>useUnicode=true<span class="token important">&amp;characterEncoding</span>=UTF<span class="token punctuation">-</span>8<span class="token important">&amp;useSSL</span>=false<span class="token important">&amp;serverTimezone</span>=Asia/Shanghai

    <span class="token key atrule">driver-class-name</span><span class="token punctuation">:</span> com.mysql.jdbc.Driver

    <span class="token key atrule">username</span><span class="token punctuation">:</span> root

    <span class="token key atrule">password</span><span class="token punctuation">:</span> <span class="token number">123456</span></code></pre>
<p>2、在 coupon 命名空间下 新建配置</p>
<p>Data ID：mybatis.yml</p>
<p>Group：dev</p>
<p>配置格式：YAML</p>
<p>配置内容：</p>
<pre class=" language-yaml"><code class="language-yaml"><span class="token key atrule">mybatis-plus</span><span class="token punctuation">:</span>

  <span class="token key atrule">mapper-locations</span><span class="token punctuation">:</span> classpath<span class="token punctuation">:</span>/mapper/**/*.xml

  <span class="token key atrule">global-config</span><span class="token punctuation">:</span>

    <span class="token key atrule">db-config</span><span class="token punctuation">:</span>

      <span class="token key atrule">id-type</span><span class="token punctuation">:</span> auto

      <span class="token key atrule">logic-delete-value</span><span class="token punctuation">:</span> <span class="token number">1</span>

      <span class="token key atrule">logic-not-delete-value</span><span class="token punctuation">:</span> <span class="token number">0</span></code></pre>
<p>3、在 coupon 命名空间下 新建配置</p>
<p>Data ID：other.yml</p>
<p>Group：dev</p>
<p>配置格式：YAML</p>
<p>配置内容：</p>
<pre class=" language-yaml"><code class="language-yaml"><span class="token key atrule">spring</span><span class="token punctuation">:</span>

  <span class="token key atrule">application</span><span class="token punctuation">:</span>

    <span class="token key atrule">name</span><span class="token punctuation">:</span> gulimall<span class="token punctuation">-</span>coupon

  <span class="token key atrule">jackson</span><span class="token punctuation">:</span>

    <span class="token key atrule">date-format</span><span class="token punctuation">:</span> yyyy<span class="token punctuation">-</span>MM<span class="token punctuation">-</span>dd HH<span class="token punctuation">:</span>mm<span class="token punctuation">:</span>ss

  <span class="token key atrule">cloud</span><span class="token punctuation">:</span>

    <span class="token key atrule">nacos</span><span class="token punctuation">:</span>

      <span class="token key atrule">discovery</span><span class="token punctuation">:</span>

        <span class="token key atrule">server-addr</span><span class="token punctuation">:</span> 127.0.0.1<span class="token punctuation">:</span><span class="token number">8848</span>

<span class="token key atrule">server</span><span class="token punctuation">:</span>

  <span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">3000</span>

<span class="token key atrule">logging</span><span class="token punctuation">:</span>

  <span class="token key atrule">level</span><span class="token punctuation">:</span>

    <span class="token key atrule">com.atguigu.gulimall</span><span class="token punctuation">:</span> debug</code></pre>
<p>4、修改 coupon 服务的 bootstrap.yml</p>
<pre class=" language-yaml"><code class="language-yaml"><span class="token key atrule">spring</span><span class="token punctuation">:</span>

  <span class="token key atrule">application</span><span class="token punctuation">:</span>

    <span class="token key atrule">name</span><span class="token punctuation">:</span> gulimall<span class="token punctuation">-</span>coupon

  <span class="token key atrule">cloud</span><span class="token punctuation">:</span>

    <span class="token key atrule">nacos</span><span class="token punctuation">:</span>

      <span class="token key atrule">config</span><span class="token punctuation">:</span>

        <span class="token key atrule">server-addr</span><span class="token punctuation">:</span> 127.0.0.1<span class="token punctuation">:</span><span class="token number">8848</span>

        <span class="token key atrule">namespace</span><span class="token punctuation">:</span> 29f44e4c<span class="token punctuation">-</span>08ec<span class="token punctuation">-</span>4f6b<span class="token punctuation">-</span>b89c<span class="token punctuation">-</span>2775fd72c275

        <span class="token key atrule">group</span><span class="token punctuation">:</span> dev

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">:</span><span class="token key atrule">data-id</span><span class="token punctuation">:</span> datasource.yml

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span>.group<span class="token punctuation">:</span> dev

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span>.refresh<span class="token punctuation">:</span> <span class="token boolean important">true</span>

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">:</span><span class="token key atrule">data-id</span><span class="token punctuation">:</span> mybatis.yml

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span>.group<span class="token punctuation">:</span> dev

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span>.refresh<span class="token punctuation">:</span> <span class="token boolean important">true</span>

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">:</span><span class="token key atrule">data-id</span><span class="token punctuation">:</span> other.yml

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span>.group<span class="token punctuation">:</span> dev

        ext<span class="token punctuation">-</span>config<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span>.refresh<span class="token punctuation">:</span> <span class="token boolean important">true</span></code></pre>
<p>5、注释掉 application.yml 的配置</p>
<p>将 application.yml 配置注释后，启动服务</p>
<pre class=" language-java"><code class="language-java"><span class="token operator">:</span><span class="token operator">:</span> Spring Boot <span class="token operator">:</span><span class="token operator">:</span>        <span class="token punctuation">(</span>v2<span class="token number">.2</span><span class="token punctuation">.</span><span class="token number">2</span><span class="token punctuation">.</span>RELEASE<span class="token punctuation">)</span>

<span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">18</span><span class="token operator">:</span><span class="token number">42.168</span>  INFO <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>  restartedMain<span class="token punctuation">]</span> c<span class="token punctuation">.</span>a<span class="token punctuation">.</span>c<span class="token punctuation">.</span>n<span class="token punctuation">.</span>c<span class="token punctuation">.</span>NacosPropertySourceBuilder     <span class="token operator">:</span> Loading nacos data<span class="token punctuation">,</span> dataId<span class="token operator">:</span> <span class="token string">'datasource.yml'</span><span class="token punctuation">,</span> group<span class="token operator">:</span> <span class="token string">'dev'</span>

<span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">18</span><span class="token operator">:</span><span class="token number">42.174</span>  INFO <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>  restartedMain<span class="token punctuation">]</span> c<span class="token punctuation">.</span>a<span class="token punctuation">.</span>c<span class="token punctuation">.</span>n<span class="token punctuation">.</span>c<span class="token punctuation">.</span>NacosPropertySourceBuilder     <span class="token operator">:</span> Loading nacos data<span class="token punctuation">,</span> dataId<span class="token operator">:</span> <span class="token string">'mybatis.yml'</span><span class="token punctuation">,</span> group<span class="token operator">:</span> <span class="token string">'dev'</span>

<span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">18</span><span class="token operator">:</span><span class="token number">42.178</span>  INFO <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>  restartedMain<span class="token punctuation">]</span> c<span class="token punctuation">.</span>a<span class="token punctuation">.</span>c<span class="token punctuation">.</span>n<span class="token punctuation">.</span>c<span class="token punctuation">.</span>NacosPropertySourceBuilder     <span class="token operator">:</span> Loading nacos data<span class="token punctuation">,</span> dataId<span class="token operator">:</span> <span class="token string">'other.yml'</span><span class="token punctuation">,</span> group<span class="token operator">:</span> <span class="token string">'dev'</span>

<span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">18</span><span class="token operator">:</span><span class="token number">42.183</span>  INFO <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>  restartedMain<span class="token punctuation">]</span> c<span class="token punctuation">.</span>a<span class="token punctuation">.</span>c<span class="token punctuation">.</span>n<span class="token punctuation">.</span>c<span class="token punctuation">.</span>NacosPropertySourceBuilder     <span class="token operator">:</span> Loading nacos data<span class="token punctuation">,</span> dataId<span class="token operator">:</span> <span class="token string">'gulimall-coupon.properties'</span><span class="token punctuation">,</span> group<span class="token operator">:</span> <span class="token string">'dev'</span>

<span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">18</span><span class="token operator">:</span><span class="token number">42.184</span>  INFO <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>  restartedMain<span class="token punctuation">]</span> b<span class="token punctuation">.</span>c<span class="token punctuation">.</span>PropertySourceBootstrapConfiguration <span class="token operator">:</span> Located property source<span class="token operator">:</span> <span class="token punctuation">[</span>BootstrapPropertySource <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>name<span class="token operator">=</span><span class="token string">'bootstrapProperties-gulimall-coupon.properties'</span><span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span> BootstrapPropertySource <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>name<span class="token operator">=</span><span class="token string">'bootstrapProperties-other.yml'</span><span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span> BootstrapPropertySource <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>name<span class="token operator">=</span><span class="token string">'bootstrapProperties-mybatis.yml'</span><span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">,</span> BootstrapPropertySource <span class="token operator">&amp;</span>#<span class="token number">123</span><span class="token punctuation">;</span>name<span class="token operator">=</span><span class="token string">'bootstrapProperties-datasource.yml'</span><span class="token operator">&amp;</span>#<span class="token number">125</span><span class="token punctuation">;</span><span class="token punctuation">]</span>

<span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">18</span><span class="token operator">:</span><span class="token number">42.209</span>  INFO <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>  restartedMain<span class="token punctuation">]</span> c<span class="token punctuation">.</span>a<span class="token punctuation">.</span>gulimall<span class="token punctuation">.</span>coupon<span class="token punctuation">.</span>CouponApplication    <span class="token operator">:</span> No active profile set<span class="token punctuation">,</span> falling back to <span class="token keyword">default</span> profiles<span class="token operator">:</span> <span class="token keyword">default</span></code></pre>
<p>访问：<a target="_blank" rel="noopener" href="http://localhost:3000/coupon/coupon/test">http://localhost:3000/coupon/coupon/test</a></p>
<pre class=" language-json"><code class="language-json">&amp;#<span class="token number">123</span><span class="token punctuation">;</span><span class="token property">"msg"</span><span class="token operator">:</span><span class="token string">"success"</span><span class="token punctuation">,</span><span class="token property">"useAge"</span><span class="token operator">:</span><span class="token string">"18"</span><span class="token punctuation">,</span><span class="token property">"code"</span><span class="token operator">:</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token property">"useName"</span><span class="token operator">:</span><span class="token string">"don"</span>&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<p>访问：<a target="_blank" rel="noopener" href="http://localhost:3000/coupon/coupon/list">http://localhost:3000/coupon/coupon/list</a></p>
<p>后台打印：</p>
<pre class=" language-java"><code class="language-java"><span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">21</span><span class="token operator">:</span><span class="token number">41.372</span> DEBUG <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>nio<span class="token operator">-</span><span class="token number">3000</span><span class="token operator">-</span>exec<span class="token operator">-</span><span class="token number">5</span><span class="token punctuation">]</span> c<span class="token punctuation">.</span>a<span class="token punctuation">.</span>g<span class="token punctuation">.</span>coupon<span class="token punctuation">.</span>dao<span class="token punctuation">.</span>CouponDao<span class="token punctuation">.</span>selectPage    <span class="token operator">:</span> <span class="token operator">==</span><span class="token operator">></span>  Preparing<span class="token operator">:</span> SELECT id<span class="token punctuation">,</span>min_point<span class="token punctuation">,</span>note<span class="token punctuation">,</span>amount<span class="token punctuation">,</span>coupon_name<span class="token punctuation">,</span>code<span class="token punctuation">,</span>member_level<span class="token punctuation">,</span>num<span class="token punctuation">,</span>enable_end_time<span class="token punctuation">,</span>use_type<span class="token punctuation">,</span>enable_start_time<span class="token punctuation">,</span>coupon_type<span class="token punctuation">,</span>publish<span class="token punctuation">,</span>receive_count<span class="token punctuation">,</span>start_time<span class="token punctuation">,</span>use_count<span class="token punctuation">,</span>end_time<span class="token punctuation">,</span>coupon_img<span class="token punctuation">,</span>publish_count<span class="token punctuation">,</span>per_limit FROM sms_coupon

<span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">21</span><span class="token operator">:</span><span class="token number">41.399</span> DEBUG <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>nio<span class="token operator">-</span><span class="token number">3000</span><span class="token operator">-</span>exec<span class="token operator">-</span><span class="token number">5</span><span class="token punctuation">]</span> c<span class="token punctuation">.</span>a<span class="token punctuation">.</span>g<span class="token punctuation">.</span>coupon<span class="token punctuation">.</span>dao<span class="token punctuation">.</span>CouponDao<span class="token punctuation">.</span>selectPage    <span class="token operator">:</span> <span class="token operator">==</span><span class="token operator">></span> Parameters<span class="token operator">:</span>

<span class="token number">2020</span><span class="token operator">-</span><span class="token number">07</span><span class="token operator">-</span><span class="token number">10</span> <span class="token number">10</span><span class="token operator">:</span><span class="token number">21</span><span class="token operator">:</span><span class="token number">41.417</span> DEBUG <span class="token number">4620</span> <span class="token operator">--</span><span class="token operator">-</span> <span class="token punctuation">[</span>nio<span class="token operator">-</span><span class="token number">3000</span><span class="token operator">-</span>exec<span class="token operator">-</span><span class="token number">5</span><span class="token punctuation">]</span> c<span class="token punctuation">.</span>a<span class="token punctuation">.</span>g<span class="token punctuation">.</span>coupon<span class="token punctuation">.</span>dao<span class="token punctuation">.</span>CouponDao<span class="token punctuation">.</span>selectPage    <span class="token operator">:</span> <span class="token operator">&lt;=</span><span class="token operator">=</span>      Total<span class="token operator">:</span> <span class="token number">0</span></code></pre>
<p>返回结果：</p>
<pre class=" language-json"><code class="language-json">&amp;#<span class="token number">123</span><span class="token punctuation">;</span><span class="token property">"msg"</span><span class="token operator">:</span><span class="token string">"success"</span><span class="token punctuation">,</span><span class="token property">"code"</span><span class="token operator">:</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token property">"page"</span><span class="token operator">:</span>&amp;#<span class="token number">123</span><span class="token punctuation">;</span><span class="token property">"totalCount"</span><span class="token operator">:</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token property">"pageSize"</span><span class="token operator">:</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token property">"totalPage"</span><span class="token operator">:</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token property">"currPage"</span><span class="token operator">:</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token property">"list"</span><span class="token operator">:</span><span class="token punctuation">[</span><span class="token punctuation">]</span>&amp;#<span class="token number">125</span><span class="token punctuation">;</span>&amp;#<span class="token number">125</span><span class="token punctuation">;</span></code></pre>
<h3 id="5、SpringCloud-Gateway-网关"><a href="#5、SpringCloud-Gateway-网关" class="headerlink" title="5、SpringCloud- Gateway 网关"></a>5、SpringCloud- Gateway 网关</h3><h4 id="1）简介-2"><a href="#1）简介-2" class="headerlink" title="1）简介"></a>1）简介</h4><p>网关作为流量的入口，常用功能包括路由转发、权限校验、限流控制等。而 spring cloud gateway 作为 Spring Cloud 官方推出的第二代网关框架，取代了 Zuul 网关。</p>
<p>网关提供 API 全托管服务，丰富的 API 管理功能，辅助企业管理大规模的 API，以降低管理成本和安全风险，包括协议适配、协议转发、安全策略、防刷、流量、监控日志等功能。</p>
<p>Spring Cloud Gateway 旨在提供一种简单而有效的方式来对 API 进行路由，并为他们提供切面，例如：安全性，监控/指标和弹性等。</p>
<p>官方文档地址：<a target="_blank" rel="noopener" href="https://cloud.spring.io/spring-cloud-static/spring-cloud-gateway/2.2.3.RELEASE/reference/html/">https://cloud.spring.io/spring-cloud-static/spring-cloud-gateway/2.2.3.RELEASE/reference/html/</a></p>
<h4 id="2）核心概念"><a href="#2）核心概念" class="headerlink" title="2）核心概念"></a>2）核心概念</h4><p>路由</p>
<p>Route: The basic building block of the gateway. It is defined by an ID, a destination URI, a collection of predicates, and a collection of filters. A route is matched if the aggregate predicate is true.</p>
<p>断言</p>
<p>Predicate: This is a Java 8 Function Predicate. The input type is a Spring Framework ServerWebExchange. This lets you match on anything from the HTTP request, such as headers or parameters.</p>
<p>过滤器</p>
<p>Filter: These are instances of Spring Framework GatewayFilter that have been constructed with a specific factory. Here, you can modify requests and responses before or after sending the downstream request.</p>
<h4 id="3）使用"><a href="#3）使用" class="headerlink" title="3）使用"></a>3）使用</h4><p>1、HelloWorld</p>
<p>创建模块 gulimall-gateway</p>
<p>引入依赖</p>
<pre class=" language-xml"><code class="language-xml"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">></span></span>org.springframework.cloud<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">></span></span>spring-cloud-starter-gateway<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">></span></span></code></pre>
<p>开启服务注册发现 <code>@EnableDiscoveryClient</code></p>
<p>配置 nacos 的注册中心地址</p>
<p>bootstrap.yml</p>
<pre class=" language-yaml"><code class="language-yaml"><span class="token key atrule">spring</span><span class="token punctuation">:</span>

  <span class="token key atrule">application</span><span class="token punctuation">:</span>

    <span class="token key atrule">name</span><span class="token punctuation">:</span> gulimall<span class="token punctuation">-</span>gareway

  <span class="token key atrule">cloud</span><span class="token punctuation">:</span>

    <span class="token key atrule">nacos</span><span class="token punctuation">:</span>

      <span class="token key atrule">config</span><span class="token punctuation">:</span>

        <span class="token key atrule">server-addr</span><span class="token punctuation">:</span> 127.0.0.1<span class="token punctuation">:</span><span class="token number">8848</span>

        <span class="token key atrule">namespace</span><span class="token punctuation">:</span> d6a49c61<span class="token punctuation">-</span>7ff2<span class="token punctuation">-</span>41fa<span class="token punctuation">-</span>a2df<span class="token punctuation">-</span>1d0783b118f6

        <span class="token key atrule">group</span><span class="token punctuation">:</span> dev</code></pre>
<p>application.properties</p>
<pre class=" language-properties"><code class="language-properties"><span class="token attr-name">server.port</span><span class="token punctuation">=</span><span class="token attr-value">88</span>

<span class="token attr-name">spring.application.name</span><span class="token punctuation">=</span><span class="token attr-value">gulimall-gareway</span>

<span class="token attr-name">spring.cloud.nacos.discovery.server-addr</span><span class="token punctuation">=</span><span class="token attr-value">127.0.0.1:8848</span></code></pre>
<p>编写网关配置文件</p>
<p>application.yml</p>
<pre class=" language-yaml"><code class="language-yaml"><span class="token key atrule">spring</span><span class="token punctuation">:</span>

  <span class="token key atrule">cloud</span><span class="token punctuation">:</span>

    <span class="token key atrule">gateway</span><span class="token punctuation">:</span>

      <span class="token key atrule">routes</span><span class="token punctuation">:</span>  <span class="token comment" spellcheck="true"># 数组</span>

        <span class="token punctuation">-</span> <span class="token key atrule">id</span><span class="token punctuation">:</span> baidu_route  <span class="token comment" spellcheck="true"># 数组1</span>

          <span class="token key atrule">uri</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//www.baidu.com

          <span class="token key atrule">predicates</span><span class="token punctuation">:</span>

            <span class="token punctuation">-</span> Query=url<span class="token punctuation">,</span>baidu

        <span class="token punctuation">-</span> <span class="token key atrule">id</span><span class="token punctuation">:</span> qq_route      <span class="token comment" spellcheck="true"># 数组2</span>

          <span class="token key atrule">uri</span><span class="token punctuation">:</span> https<span class="token punctuation">:</span>//www.qq.com

          <span class="token key atrule">predicates</span><span class="token punctuation">:</span>

            <span class="token punctuation">-</span> Query=url<span class="token punctuation">,</span>qq</code></pre>
<p>启动服务测试</p>
<pre><code>http://localhost:88/hello?url=qq
http://localhost:88/hello?url=baidu</code></pre>
<p>2、断言 （predicates）</p>
<p>3、过滤器 （filters）</p>
<script>
        document.querySelectorAll('.github-emoji')
          .forEach(el => {
            if (!el.dataset.src) { return; }
            const img = document.createElement('img');
            img.style = 'display:none !important;';
            img.src = el.dataset.src;
            img.addEventListener('error', () => {
              img.remove();
              el.style.color = 'inherit';
              el.style.backgroundImage = 'none';
              el.style.background = 'none';
            });
            img.addEventListener('load', () => {
              img.remove();
            });
            document.body.appendChild(img);
          });
      </script>
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">guoxiaolong</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://carlosgxl.gitee.io/blog/2020/08/10/xiang-mu-bei-jing/">http://carlosgxl.gitee.io/blog/2020/08/10/xiang-mu-bei-jing/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">guoxiaolong</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            <span class="chip bg-color">无标签</span>
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2020/08/10/huan-cun-springcache/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/0.jpg" class="responsive-img" alt="">
                        
                        <span class="card-title"></span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            缓存-SpringCacheSpringCache概述Spring 3.1 引入了激动人心的基于注释（annotation）的缓存（cache）技术，它本质上不是一个具体的缓存实现方案（例如 EHCache 或者 OSCache），而是一个
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-08-10
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            guoxiaolong
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2020/08/09/hello-world/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/12.jpg" class="responsive-img" alt="Hello World">
                        
                        <span class="card-title">Hello World</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hex
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-08-09
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            guoxiaolong
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='true'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">2019</span>
            <a href="/about" target="_blank">guoxiaolong</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/Guo119741" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:1197814431@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1197814431" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1197814431" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/search.xml", 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
